package o;

import android.content.Context;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import com.huawei.android.immersion.ImmersionStyle;
import com.huawei.fastengine.BuildConfig;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import o.ayt.c;

public final class azc {
    private static azc ˋ;
    private static final Map<Integer, String> ॱ = new HashMap();
    private Integer ʻ = null;
    private int ˊ = ʼ();
    private String ˎ;
    private String ˏ;
    private Integer ॱॱ = null;

    static {
        ॱ.put(Integer.valueOf(1), BuildConfig.VERSION_NAME);
        ॱ.put(Integer.valueOf(2), "1.5");
        ॱ.put(Integer.valueOf(3), "1.6");
        ॱ.put(Integer.valueOf(4), "2.0");
        ॱ.put(Integer.valueOf(5), "2.0");
        ॱ.put(Integer.valueOf(6), "2.3");
        ॱ.put(Integer.valueOf(7), "3.0");
        ॱ.put(Integer.valueOf(8), "3.0.5");
        ॱ.put(Integer.valueOf(8), "3.1");
        ॱ.put(Integer.valueOf(9), "4.0");
        ॱ.put(Integer.valueOf(10), "4.1");
        ॱ.put(Integer.valueOf(11), "5.0");
        ॱ.put(Integer.valueOf(12), "5.1");
        ॱ.put(Integer.valueOf(13), "5.1");
        ॱ.put(Integer.valueOf(14), "8.0");
        ॱ.put(Integer.valueOf(15), "8.1");
        ॱ.put(Integer.valueOf(16), "8.2");
        ॱ.put(Integer.valueOf(17), "9.0");
        ॱ.put(Integer.valueOf(18), "9.0.1");
        ॱ.put(Integer.valueOf(19), "9.1");
        ॱ.put(Integer.valueOf(20), "9.1.1");
        ॱ.put(Integer.valueOf(21), "10.0");
        ॱ.put(Integer.valueOf(22), "10.0.1");
        ॱ.put(Integer.valueOf(23), "10.1");
    }

    private azc() {
        if (this.ˊ == 0) {
            this.ˊ = ˋॱ();
        }
        this.ˎ = ˊॱ();
        this.ˏ = ˏॱ();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("emuiVersion:").append(this.ˊ).append(", emuiVersionName:").append(this.ˎ).append(", magicUIVersionName:").append(this.ˏ);
        ayv.ˎ.ˋ("EMUISupportUtil", stringBuilder.toString());
        ˎ(ContentManager.getInstant().getContext());
    }

    public static synchronized azc ˎ() {
        azc o_azc;
        synchronized (azc.class) {
            if (ˋ == null) {
                ˋ = new azc();
            }
            o_azc = ˋ;
        }
        return o_azc;
    }

    public static int ˋ(Context context) {
        int i = 1;
        try {
            i = ImmersionStyle.getSuggestionForgroundColorStyle(ImmersionStyle.getPrimaryColor(context));
        } catch (NoSuchMethodError e) {
            ayv.ˎ.ˏ("EMUISupportUtil", "getSuggestionForgroundColor NoSuchMethodError error" + e.toString());
        } catch (NoClassDefFoundError e2) {
            ayv.ˎ.ˏ("EMUISupportUtil", "getSuggestionForgroundColor NoClassDefFoundError error" + e2.toString());
        } catch (Exception e3) {
            ayv.ˎ.ˏ("EMUISupportUtil", "get fwk primary color or suggestforgroundcolor error!" + e3.toString());
        }
        return i;
    }

    public static Context ॱ(Context context) {
        try {
            int identifier = context.getResources().getIdentifier("androidhwext:style/Theme.Emui", null, null);
            if (identifier > 0) {
                return new ContextThemeWrapper(context, identifier);
            }
            return context;
        } catch (Throwable e) {
            ayv.ˎ.ˊ("StoreApplication", "Can't get EMUIAppContext:", e);
            return context;
        }
    }

    private void ˎ(Context context) {
        try {
            Resources resources = context.getResources();
            int identifier = resources.getIdentifier("emui_action_bar_title_text_color", "color", "androidhwext");
            int identifier2 = resources.getIdentifier("emui_action_bar_title_text_color_light", "color", "androidhwext");
            if (identifier > 0) {
                this.ʻ = Integer.valueOf(resources.getColor(identifier));
            }
            if (identifier2 > 0) {
                this.ॱॱ = Integer.valueOf(resources.getColor(identifier2));
            }
        } catch (Throwable e) {
            ayv.ˎ.ˊ("EMUISupportUtil", "init fwk color error!", e);
        }
    }

    private int ʼ() {
        return bmm.getSystemProperty("ro.build.hw_emui_api_level", 0);
    }

    private String ˏॱ() {
        return bmm.getSystemProperty("ro.build.version.magic", "");
    }

    private int ˋॱ() {
        Object ˊ = ˊ(bmm.getSystemProperty("ro.build.version.emui", ""));
        if (!TextUtils.isEmpty(ˊ)) {
            for (Entry entry : ॱ.entrySet()) {
                if (ˊ.startsWith((String) entry.getValue())) {
                    return ((Integer) entry.getKey()).intValue();
                }
            }
        }
        return 0;
    }

    private String ˊ(String str) {
        String str2 = "";
        if (TextUtils.isEmpty(str)) {
            return str2;
        }
        String[] split = str.split("_");
        if (split.length == 2) {
            return split[1];
        }
        return str2;
    }

    public String ˏ() {
        return bmm.getSystemProperty("ro.build.version.emui", "");
    }

    private String ˊॱ() {
        String str = (String) ॱ.get(Integer.valueOf(this.ˊ));
        if (str == null) {
            return "";
        }
        return str;
    }

    public int ॱ() {
        return this.ˊ;
    }

    public String ˋ() {
        return this.ˎ;
    }

    public String ˊ() {
        return this.ˏ;
    }

    public boolean ॱॱ() {
        return this.ˊ >= 9;
    }

    public boolean ᐝ() {
        return this.ˊ >= 11;
    }

    public int ʽ() {
        if (this.ʻ != null) {
            return this.ʻ.intValue();
        }
        return ContentManager.getInstant().getContext().getResources().getColor(c.ॱ);
    }

    public int ʻ() {
        if (this.ॱॱ != null) {
            return this.ॱॱ.intValue();
        }
        return ContentManager.getInstant().getContext().getResources().getColor(c.ˋ);
    }
}
